using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Widgetsphere.Generator.Common.GeneratorFramework
{
  public abstract class BaseModelCollection : BaseModelObject, ICollection, IEnumerable
  {
    public BaseModelCollection(IModelObject root)
      : base(root)
    {
    }

    #region Methods

    public virtual Array Find(string key)
    {
      try
      {
        ArrayList retval = new ArrayList();
        foreach (IModelObject element in this)
        {
          if (string.Compare(element.Key, key, true) == 0)
            retval.Add(element);
        }
        return retval.ToArray();
      }
      catch (Exception ex)
      {
        throw;
      }
    }

    public abstract void Clear();
    public abstract void AddRange(ICollection list);

    #endregion

    #region IEnumerable Members

    public abstract IEnumerator GetEnumerator();

    #endregion

    #region ICollection Members

    public abstract int Count { get;}
    public abstract void CopyTo(Array array, int index);
    public abstract object SyncRoot { get;}
    public abstract bool IsSynchronized { get;}

    #endregion
  }
}
